<?php

class bean
{
	static $filds=array();
	static $tables=array();
	static $foreigns=array();
	
	
	static function tables()
	{
		$table=array(
			'u'=>'user',
			'g'=>'goods',
			'b'=>'books');
		self::$tables=$table;
	}
	
	static function fild()
	{
		$fild['user']=array('user_id','user_name','user_psw');
		$fild['goods']=array('goods_id','goods_name','user_id');
		$fild['books']=array('books_id','books_name','books_sn');
		self::$filds=$fild;
	}
	
	static function foreign()
	{
		$table['user']['user_id']=$table['goods']['user_id'];
		return $table;
	}
	
	
	static function getsql($target,$filter=array())
	{
		$key=self::getKey($filter,'key','string');
		if(!in_array(self::$filds[$target], $key))
		{
			
		}
		
	}
	
	
	static function getKey($array,$return='all',$type='array')
	{
		foreach($array as $k =>$v)
		{
			$key[]=$k;
			$val[]=$v;
		}
		if($type=='string')
		{
			$key=implode(',', $key);
			$val=implode(',', $val);
		}
		switch($return)
		{
			case 'key':return $key;
			case 'val':return $val;
			default:
				return array($key,$val);
		}
	}
	
	
	function test()
	{
		$user=array(
			'fild'=>array('user_id','user_name'),
		);
		
		$book=array(
			'fild'=>array('book_id','user_id'),
			'foreign'=>array(
				'user_id'=>$user['user_id']
			)
		);
		
		date_format();
	
	}
	
	
}